package com.hooper.hosp.controller;

import com.hooper.hosp.model.hosp.Schedule;
import com.hooper.hosp.service.ScheduleService;
import com.hooper.hosp.vo.PageVo;
import com.hooper.hospital.common.result.Result;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author Tim Hooper
 * @version 1.0
 * @time 2022/10/01/18:44
 */
@Api("department controller")
@RestController
@Slf4j
//@CrossOrigin
@RequiredArgsConstructor
@RequestMapping("/admin/hosp/schedule")
public class ScheduleController {

    private final ScheduleService scheduleService;

    @GetMapping("getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getScheduleRule(@PathVariable int page,
                                  @PathVariable int limit,
                                  @PathVariable String hoscode,
                                  @PathVariable String depcode) {
        Map<String, Object> map
                = scheduleService.findAllByHoscodeAndDepcode(page, limit, hoscode, depcode);
        return Result.ok(map);
    }

    @GetMapping("/detail/{hoscode}/{depcode}/{workDate}")
    public Result detail(@PathVariable String depcode, @PathVariable String workDate, @PathVariable String hoscode) {
        List<Schedule> detailList = scheduleService.getDetail(depcode, hoscode, workDate);
        return Result.ok(detailList);
    }
}
